﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace DeviceDebugger.Converter
{
    class ConverterCreateTaskFilter : IMultiValueConverter
    {
        /// <summary>
        /// 适用于调试界面生成任务按钮及自动生成GroupBox组的禁用
        /// </summary>
        /// <param name="values"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values.Length > 0)
            {
                if (values.Length >= 2)
                {
                    //判断执行方式是自动或者半自动中的任意一个
                    if (values[0] is bool && values[1] is bool && ((bool)values[0] || (bool)values[1]))
                    {
                        if (values.Length >= 3)
                        {
                            //判断生成按钮是否可用
                            if (values[2] is int && (int)values[2] == 0)
                                return true;
                            else
                                return false;
                        }
                        return true;
                    }
                    else
                        return false;
                }
            }
            return true;
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
